﻿<%@ Page Title="Inquiry Outgoing Transmittal" Language="C#" MasterPageFile="~/eTransmittal.Master" AutoEventWireup="true" CodeBehind="InquiryOutgoing.aspx.cs" Inherits="POI.eTransmittal.WebApp.InquiryOutgoing" %>

<%@ Register Assembly="DevExpress.Web.v11.2, Version=11.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxRoundPanel" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v11.2, Version=11.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxPanel" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.ASPxGridView.v11.2, Version=11.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxGridView" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.ASPxEditors.v11.2, Version=11.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxEditors" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v11.2, Version=11.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxSplitter" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Xpo.v11.2.Web, Version=11.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Xpo" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v11.2, Version=11.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxPopupControl" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v11.2, Version=11.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxUploadControl" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v11.2, Version=11.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxCallbackPanel" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v11.2, Version=11.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxHiddenField" TagPrefix="dx" %>
<%@ Register assembly="DevExpress.Web.v11.2, Version=11.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxCallback" tagprefix="dx" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContentPlaceHolder" runat="server">
    <dx:ASPxGridView ID="grdTransmittal" runat="server" AutoGenerateColumns="False" 
        ClientInstanceName="grdTransmittal" DataSourceID="xpodsTransmittal" 
        KeyFieldName="ID" oncustomcallback="grdTransmittal_CustomCallback" 
        Width="100%" onrowdeleting="grdTransmittal_RowDeleting" 
        oncommandbuttoninitialize="grdTransmittal_CommandButtonInitialize" 
        oncustombuttoninitialize="grdTransmittal_CustomButtonInitialize">
        <ClientSideEvents CustomButtonClick="function(s, e) {
	onEdit(s,e);
}" />
        <Columns>
            <dx:GridViewDataTextColumn FieldName="DocTypeName" VisibleIndex="2" 
                Caption="Type" Width="60px">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn FieldName="Subject" 
                VisibleIndex="3">
                <DataItemTemplate>
                            <%#Eval("UNC_LINK") == "" || Eval("UNC_LINK") == null ? Container.Text : Container.Text + "&nbsp;<img src='images/attachment.png' />"%>
                             <%--   <a href="<%#Container.Text %>" target="_blank">View File</a>--%>
                </DataItemTemplate>
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn FieldName="Author" VisibleIndex="4" Width="65px">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn FieldName="Destination" VisibleIndex="6" 
                Caption="To" Width="120px">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn FieldName="Attn" Visible="False" VisibleIndex="7" 
                Width="60px">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn FieldName="RefNo" VisibleIndex="0" Width="65px" 
                SortIndex="0" SortOrder="Descending">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn FieldName="Status" 
                VisibleIndex="10" Width="40px">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataDateColumn FieldName="CreatedDate" 
                VisibleIndex="1" Width="150px">
                <PropertiesDateEdit DisplayFormatString="dd MMM yyyy  HH:mm:ss" 
                    EditFormatString="dd MMM yyyy  HH:mm:ss">
                </PropertiesDateEdit>
            </dx:GridViewDataDateColumn>
            <dx:GridViewDataTextColumn FieldName="CreatedBy" VisibleIndex="11" Width="60px">
            </dx:GridViewDataTextColumn>
            <dx:GridViewCommandColumn Caption=" " VisibleIndex="14" Width="20px">
                <DeleteButton Visible="True">
                </DeleteButton>
                <ClearFilterButton Visible="True">
                </ClearFilterButton>
                <CustomButtons>
                    <dx:GridViewCommandColumnCustomButton ID="custEdit" Text="View">
                    </dx:GridViewCommandColumnCustomButton>
                </CustomButtons>
            </dx:GridViewCommandColumn>
        </Columns>
        <Settings ShowFilterRow="True" ShowFilterRowMenu="True" ShowGroupPanel="True" />

<Settings ShowFilterRow="True"></Settings>
    </dx:ASPxGridView>
    <dx:XpoDataSource ID="xpodsTransmittal" runat="server" 
        TypeName="POI.eTransmittal.Enitity.OutgoingTransmittal">
    </dx:XpoDataSource>
    <dx:XpoDataSource ID="xpoDsContact" runat="server" 
        TypeName="POI.eTransmittal.Enitity.Contact">
    </dx:XpoDataSource>
    <dx:XpoDataSource ID="xpodsDocType" runat="server" 
        TypeName="POI.eTransmittal.Enitity.DocumentType">
    </dx:XpoDataSource>
    <dx:XpoDataSource ID="xpodsUser" runat="server" 
        TypeName="POI.eTransmittal.Enitity.TransmittalUser">
    </dx:XpoDataSource>
    <dx:ASPxCallback ID="clbCancel" runat="server" ClientInstanceName="clbCancel" 
        oncallback="clbCancel_Callback">
        <ClientSideEvents CallbackComplete="function(s, e) {
	OnUploadCanceled(e);
}" />
    </dx:ASPxCallback>
    <dx:ASPxPopupControl ID="popEdit" runat="server" Width="800px" 
        ClientInstanceName="popEdit" HeaderText="Edit Outgoing Transmittal" 
        Modal="True" PopupHorizontalAlign="WindowCenter" 
        PopupVerticalAlign="WindowCenter" AllowDragging="True" Height="600px">
        <ClientSideEvents Shown="function(s, e) {
	clbpnlPopEdit.PerformCallback('load;'+transIDtoShow.toString());
}" />
        <ContentCollection>
<dx:PopupControlContentControl runat="server" SupportsDisabledAttribute="True">
    
     <table width="100%">
     <tr>
     <td>
     <dx:ASPxCallbackPanel ID="clbpnlPopEdit" runat="server" Width="100%" 
        OnCallback="clbpnlPopEdit_Callback" ClientInstanceName="clbpnlPopEdit">
        <ClientSideEvents CallbackError="function(s, e) {

}" EndCallback="function(s, e) {
		handlePopEditInfo();
}" />
        <PanelCollection>
            <dx:PanelContent ID="PanelContent1" runat="server" SupportsDisabledAttribute="True">
<table width="100%">
    <tr>
        <td>
            Subject</td>
        <td valign="top" bgcolor="#CCCCCC" width="300">
            <dx:ASPxTextBox ID="txtEditSubject" runat="server" 
                ClientInstanceName="txtEditSubject" Width="100%">
            </dx:ASPxTextBox>
        </td>
        <td>
            </td>
        <td>
            Log No.</td>
        <td bgcolor="#CCCCCC" style="padding-left: 5px">
            <dx:ASPxLabel ID="lblLog" runat="server" ClientInstanceName="lblNo" 
                Text="(auto generated)">
            </dx:ASPxLabel>
        </td>
    </tr>
<tr><td>Author</td><td valign="top" bgcolor="#CCCCCC">
    <dx:ASPxComboBox ID="cboAuthor" runat="server" CallbackPageSize="10" 
        ClientInstanceName="cboAuthor" DataSourceID="xpodsUser" 
        DropDownStyle="DropDown" EnableCallbackMode="True" 
        EnableIncrementalFiltering="True" IncrementalFilteringMode="StartsWith" 
        TextField="Name" ValueField="UserID">
    </dx:ASPxComboBox>
    </td><td></td><td>Ref No.</td><td bgcolor="#CCCCCC" style="padding-left: 5px"><dx:ASPxLabel 
        ID="lblRefNo" runat="server" ClientInstanceName="lblRefNo">
    </dx:ASPxLabel>
    </td></tr>
    <tr>
        <td>
            To</td>
        <td valign="top" bgcolor="#CCCCCC">
            <dx:ASPxComboBox ID="cboEditTo" runat="server" ClientInstanceName="cboEditTo" 
                DataSourceID="xpoDsContact" DropDownStyle="DropDown" TextField="Name" 
                ValueField="Name">
            </dx:ASPxComboBox>
        </td>
        <td>
            </td>
        <td>
            Document Type</td>
        <td valign="top" bgcolor="#CCCCCC">
            <dx:ASPxComboBox ID="cboEditDocType" runat="server" 
                ClientInstanceName="cboEditDocType" DataSourceID="xpodsDocType" 
                DropDownStyle="DropDown" TextField="TypeName" ValueField="Code">
                <ClientSideEvents SelectedIndexChanged="function(s, e) {
	OnDocTypeChanged(s,e);
}" />
            </dx:ASPxComboBox>
        </td>
    </tr>
    <tr>
        <td>
            Fax No</td>
        <td valign="top" bgcolor="#CCCCCC">
            <dx:ASPxTextBox ID="txtEditFaxNo" runat="server" 
                ClientInstanceName="txtEditFaxNo" Width="170px">
            </dx:ASPxTextBox>
        </td>
        <td>
            &nbsp;</td>
        <td rowspan="1">
            File</td>
        <td rowspan="1" bgcolor="#CCCCCC" width="280">
            <table cellpadding="0" cellspacing="0" style="width:100%;">
                <tr>
                    <td align="center">
                        <dx:ASPxButton ID="btnChange" runat="server" AutoPostBack="False" 
                            ClientInstanceName="btnChange" Width="280px">
                            <ClientSideEvents Click="function(s, e) {
if(s.GetText() != 'Cancel')
{
	s.SetText('Cancel');
	toggleUpload('change');
}
else{
	//s.SetText('Change File');
	clbCancel.PerformCallback(transIDtoShow);
}
}" />
                        </dx:ASPxButton>
                        <dx:ASPxUploadControl ID="upcDocument" runat="server" 
                            ClientInstanceName="upcDocument" ClientVisible="False" 
                            OnFileUploadComplete="upcDocument_FileUploadComplete" ShowUploadButton="True" 
                            Width="280px">
                            <ValidationSettings MultiSelectionErrorText="Attention! 

The following {0} files are invalid because they exceed the allowed file size ({1}) or their extensions are not allowed. These files have been removed from selection, so they will not be uploaded. 

{2}">
                            </ValidationSettings>
                            <ClientSideEvents FileUploadComplete="function(s, e) {
	onUploadComplete(e);
}" />
                        </dx:ASPxUploadControl>
                    </td>
                </tr>
            </table>
        </td>
    </tr>
    <tr>
        <td>
            Attn</td>
        <td valign="top" bgcolor="#CCCCCC">
            <dx:ASPxTextBox ID="txtEditAttn" runat="server" 
                ClientInstanceName="txtEditAttn" Width="100%">
            </dx:ASPxTextBox>
        </td>
        <td>
            </td>
        <td valign="top">
            &nbsp;</td>
        <td bgcolor="#CCCCCC">
        </td>
    </tr>
    <tr>
        <td>
            Remarks</td>
        <td valign="top" bgcolor="#CCCCCC">
            <dx:ASPxTextBox ID="txtEditRemarks" runat="server" 
                ClientInstanceName="txtRemarks" Width="100%">
            </dx:ASPxTextBox>
        </td>
        <td>
            &nbsp;</td>
        <td>
            &nbsp;</td>
        <td bgcolor="#CCCCCC" style="padding-left: 5px">
            &nbsp;</td>
    </tr>
   
    <tr>
        <td valign="top">
            &nbsp;</td>
        <td valign="top">
            <dx:ASPxHiddenField ID="hfEdit" runat="server" ClientInstanceName="hfEdit" 
                OnCustomCallback="hfEdit_CustomCallback">
                <ClientSideEvents EndCallback="function(s, e) {
	onLinkUpdated(s,e);
}" />
            </dx:ASPxHiddenField>
        </td>
        <td valign="top">
            &nbsp;</td>
        <td valign="top">
            &nbsp;</td>
        <td align="right" valign="top">
            &nbsp;</td>
    </tr>
    <tr align="right" valign="top">
        <td bgcolor="Gray" colspan="5" style="border-color: #CCCCCC" valign="top">
            <table>
                <tr>
                    <td>
                        <dx:ASPxButton ID="btnSendFax" runat="server" AutoPostBack="False" 
                            Text="Send Fax">
                            <ClientSideEvents Click="function(s, e) {
	clbpnlPopEdit.PerformCallback('send;'+transIDtoShow.toString());
}" />
                        </dx:ASPxButton>
                    </td>
                    <td>
                        <dx:ASPxButton ID="btnSubmit" runat="server" AutoPostBack="False" Text="Submit">
                            <ClientSideEvents Click="function(s, e) {
	clbpnlPopEdit.PerformCallback('submit;'+transIDtoShow.toString());
}" />
                        </dx:ASPxButton>
                    </td>
                    <td>
                        <dx:ASPxButton ID="btnSave" runat="server" AutoPostBack="False" Text="Save">
                            <ClientSideEvents Click="function(s, e) {
	clbpnlPopEdit.PerformCallback('save;'+transIDtoShow.toString());
}" />
                        </dx:ASPxButton>
                    </td>
                </tr>
            </table>
        </td>
    </tr>
</table>
                <%--<table width="100%">
            <tr>
                <td valign="top" style="width:350px">
                <table width="100%" style="height:150px">
                                    <tr>
                                        <td>
                                        Subject
                                        </td>
                                        <td>
                                       
                                            &nbsp;</td>
                                    </tr>
                                    <tr>
                                        <td>
                                            Author</td>
                                        <td>
                                            &nbsp;</td>
                                    </tr>
                                    <tr>
                                        <td>
                                            To</td>
                                        <td>
                                            &nbsp;</td>
                                    </tr>
                                    <tr>
                                        <td>
                                            Fax No</td>
                                        <td>
                                            &nbsp;</td>
                                    </tr>
                                    <tr>
                                        <td>
                                            Attn</td>
                                        <td>
                                            &nbsp;</td>
                                    </tr>
                                    <tr>
                                        <td>
                                            Remarks</td>
                                        <td>
                                            &nbsp;</td>
                                    </tr>
                                </table>
                   
                </td>
                <td valign="top">
                <table width="100%" style="height:150px"><tr>
    <td valign="top" style="width:90px">Transmittal No.</td><td valign="top" >
                    &nbsp;</td></tr>
    <tr>
        <td valign="top">
            Document Type</td>
        <td valign="top">
            &nbsp;</td>
    </tr>
    <tr>
        <td valign="top">
            File</td>
        <td valign="top">
            &nbsp;</td>
    </tr>
    <tr>
        <td valign="top">
            &nbsp;</td>
        <td valign="top">
            &nbsp;</td>
    </tr>
    <tr>
        <td valign="top">
            Ready to send</td>
        <td valign="top">
            &nbsp;</td>
    </tr>
    <tr>
        <td valign="top">
            Status</td>
        <td valign="top">
            &nbsp;</td>
    </tr>
    </table>
                
                </td>
            </tr>
            <tr>
                <td>
                    &nbsp;</td>
                <td align="right">
                    </td>
            </tr>
                    
        </table>--%>

            </dx:PanelContent>
        </PanelCollection>
    </dx:ASPxCallbackPanel>
     </td>
     </tr>
                            <tr>
                                <td><iframe id="frDoc" width="100%" height="400" ></iframe></td>
                            </tr>
                            </table>
            </dx:PopupControlContentControl>
</ContentCollection>
    </dx:ASPxPopupControl>

<script type="text/javascript">

    function onEdit(s, e) {
        s.GetRowValues(e.visibleIndex, "ID;Subject", onGetIdCompleted);
    }
    var transIDtoShow = -1;
    function onGetIdCompleted(values) {
        transIDtoShow = values[0];


        popEdit.Show();
    }
    function handlePopEditInfo() {
        var isErr = hfEdit.Get('error');
        var isinfo = hfEdit.Get('info');
        var link = hfEdit.Get('uncLink');

        if (isErr != null || isErr != undefined) {
            ShowErrorMessage(hfEdit.Get('error'));
            hfEdit.Clear();
        } 
        else if (isinfo != null || isinfo != undefined) 
        {
            ShowStatusMessage(hfEdit.Get('info'));
            popEdit.Hide();
            hfEdit.Clear();
            grdTransmittal.PerformCallback();
        }
        else if (link != null || link != undefined) 
        {
            var frame = document.getElementById('frDoc');
            //alert(link);
            frame.src = link;          
        }


    }
    function toggleUpload(s) {
        var text = s;
        switch (text) {
            case 'change':
                //var dv = document.getElementById('divReadDoc');
                //dv.style.display = 'none';
                upcDocument.SetClientVisible(true);
                break;
            case 'view':
                //var dv = document.getElementById('divReadDoc');
                //dv.style.display = 'block';
                upcDocument.SetClientVisible(false);


                break;


        }
    }
    
    function onUploadComplete(e) {
        toggleUpload('view');
        btnChange.SetText(e.callbackData);
        hfEdit.PerformCallback();

    }
    function ClearEntry() {
        dteStartDate.SetText('');
        dteEndDate.SetText('');
        cboTo.SetText('');
        cboStatus.SetSelectedIndex(0);
    }
    function OnDocTypeChanged(s, e) {


    }
    function OnUploadCanceled(e) {
        btnChange.SetText(e.result);
        toggleUpload('view');
        hfEdit.PerformCallback('cancel;' + transIDtoShow);
    }
    function onLinkUpdated(s, e) {
        var link = hfEdit.Get('uncLink');
        if (link != null || link != undefined) {
            var frame = document.getElementById('frDoc');
            //alert(link);
            frame.src = link;
        }
    }
</script>

</asp:Content>
